<template>
    <div>
        <table class="table">
            <tbody>
                <tr>
                    <th>房号</th>
                    <th>
                        <input type="text" v-model="data.StoreId">
                    </th>
                </tr>
                <tr>
                    <th>房间名称</th>
                    <th>
                        <input type="text" v-model="data.Name">
                    </th>
                </tr>
                <tr>
                    <th>日期</th>
                    <th>
                        <input type="date" v-model="data.date">
                    </th>
                </tr>
                <tr>
                    <th>价格</th>
                    <th>
                        <input type="text" v-model="data.Price">
                    </th>
                </tr>
                <tr>
                    <th colspan="2">
                        <input type="button" value="添加" @click="Add">
                    </th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
    import { ref,onMounted } from 'vue';
    import axios from 'axios';  
    import { useRouter } from 'vue-router';
    const rputer = useRouter();
    const data = ref({
     "Id": 0,
    "Name": "",
    "StoreId": "",
    "date": "2025-03-10T01:21:37.908Z",
    "Price": 0
    })
    const Add=()=>{
        axios.post("https://localhost:7182/api/Store/AddStore",data.value).then(res=>{
            if(res.data==-1){
                alert('房间号不能重复')
            }
            else if(res.data>0){
                alert('添加成功')
                rputer.push({path:"/"})
            }
            else{
                alert('添加失败')
            }
        })
    }
</script>

<style scoped>

</style>